#ifndef __MSG_BOX_H
#define __MSG_BOX_H

#include "osEvent.h"


#define MSGBOX_SEND_NORMAL  0x00        /* 普通发送*/
#define MSGBOX_SEND_FRONT   0x01        /* 优先发送*/


typedef struct _MSG_BOX{
    EVENT_T event;          // 邮箱事件等待队列
    
    uint32_t count;         // 消息数量
    uint32_t maxCount;      // 最大消息数量
    void **msgBuffer;       // 消息存储缓存区
    uint32_t write_idx;     // 写消息索引
    uint32_t read_idx;      // 读消息索引
} MSG_BOX_T;

typedef struct _MSG_BOX_INFO {
    uint32_t count;         // 消息数量
    uint32_t maxCount;      // 最大消息数量
    uint32_t taskCount;     // 事件等待任务数量
} MSG_BOX_INFO_T;


extern void     vMsgBoxInit(MSG_BOX_T *msgbox, void **msgBuffer, uint32_t maxCount);

extern uint32_t vMsgBoxSend(MSG_BOX_T *msgbox, void *msg, uint32_t notifyPRI);
extern uint32_t vMsgBoxRecv(MSG_BOX_T *msgbox, void **msg, uint32_t timeout);
extern void     vMsgBoxFlush(MSG_BOX_T *msgbox);
extern uint32_t vMsgBoxDestroy(MSG_BOX_T *msgbox);
extern void     vMsgBoxGetInfo(MSG_BOX_T *msgbox, MSG_BOX_INFO_T *info);
    
#endif // __MSG_BOX_H
